home *** CD-ROM | disk | FTP | other *** search
- BEGIN {
- #{{{}}}
- # {{{ print auto-gen-mark
- print("/* This file is generated automatically by awk -f tok2h.awk */\n/* containing permission and execution-level information for OCL tokens */")
- # }}}
- # {{{ print permission constants
- print("/*{{{ permissons*/")
- # {{{ print mask constants
- print("/*{{{ bits and mask*/")
- print("#define KTI_NONE\t0\t/* no permissions\t*/")
- print("#define KTI_B\t\t1\t/* browse key\t\t*/")
- print("#define KTI_F\t\t2\t/* fieldedit key\t*/")
- print("#define KTI_S\t\t4\t/* screen key - folding\t*/")
- print("#define KTI_P\t\t8\t/* prompt key\t\t*/")
- print("#define KT_LG\t\t4\t/* number of used bits\t*/")
- print("/*}}} */")
- # }}}
- # {{{ print combined masks
- print("/*{{{ combined*/")
- print("#define KT_DUMMY\t0\t/* not used\t*/")
- print("")
- print("#define KT_NONE\t\tKTI_NONE")
- print("#define KT_B\t\tKTI_B")
- print("#define KT_F\t\tKTI_F")
- print("#define KT_S\t\tKTI_S")
- print("#define KT_P\t\tKTI_P")
- print("#define KT_PSFB\t\t(KTI_P|KTI_S|KTI_F|KTI_B)")
- print("#define KT_SFB\t\t(KTI_S|KTI_F|KTI_B)")
- print("#define KT_PFB\t\t(KTI_P|KTI_F|KTI_B)")
- print("#define KT_PSB\t\t(KTI_P|KTI_S|KTI_B)")
- print("#define KT_PSF\t\t(KTI_P|KTI_S|KTI_F)")
- print("#define KT_FB\t\t(KTI_F|KTI_B)")
- print("#define KT_PB\t\t(KTI_P|KTI_B)")
- print("#define KT_PS\t\t(KTI_P|KTI_S)")
- print("#define KT_SF\t\t(KTI_S|KTI_F)")
- print("#define KT_SB\t\t(KTI_S|KTI_B)")
- print("#define KT_PF\t\t(KTI_P|KTI_F)")
- print("/*}}} */")
- # }}}
- print("/*}}} */")
- # }}}
- # {{{ print type definition
- print("/*{{{ types*/")
- print("typedef enum")
- print(" { COM=0,\t/* simple command\t\t\t*/")
- print(" COM_C,\t/* command with 1 char argument\t\t*/")
- print(" COM_I,\t/* command with 1 int argument\t\t*/")
- print(" COM_A,\t/* command with a adress\t\t*/")
- print(" COM_II,\t/* command with 2 int arguments\t\t*/")
- print(" COM_P,\t/* command with a prompt\t\t*/")
- print(" COM_IP,\t/* command with 1 int and prompt\t*/")
- print(" COM_IIP\t/* command with 2 int and prompt\t*/")
- print(" } COM_TYPES;")
- print("/*}}} */")
- # }}}
- print("/*{{{ datalist*/")
- # {{{ P_T_MERGE
- print("#define P_T_MERGE(p,c) (p|(c<<KT_LG))")
- # }}}
- # {{{ GET_T
- print("#define GET_T(x) \\")
- print(" (((x<=O_NOP)||(x>=O_EXE_MACRO)) \\")
- print(" ? COM \\")
- print(" : (COM_TYPES)(key_info[x-O_NOP]>>KT_LG))")
- print("")
- # }}}
- printf("private char const key_info[] =\n { P_T_MERGE(KT_PSFB,COM) \t/* O_NOP */")
- # {{{ init fixed cmd arg range
- cmd_range=8
- # }}}
- }
- #{{{ set fixed cmd command range
- /^#define +FIXED_COMMAND_RANGE/ {
- cmd_range=$3
- next
- }
- #}}}
- #{{{ set types for command and fixed command
- $3=="COM" || $3=="COM_I" || $3=="COM_II" || $3=="COM_P" || $3=="COM_IP" || $3=="COM_IIP" || $3=="COM_C" { typ=$3;fix_typ="" }
- $3=="COM_A" { typ="COM_A";fix_typ="COM" }
- $3=="COM_ID" { typ="COM_II";fix_typ="COM_I" }
- $3=="COM_D" { typ="COM_I";fix_typ="COM" }
- #}}}
- #{{{ print command type and permissions
- substr($1,1,1)!="#" && $3!="OCL-KEY" && $3!="OPP-KEY" {
- # {{{ get permission, strip 's'
- p="KT_"
- i=4
- while (i<=length($2)) {
- if (substr($2,i,1)!="s") p=p substr($2,i,1)
- i++
- }
- if (p=="KT_") p="KT_NONE"
- # }}}
- if (fix_typ!="") {
- for (i=cmd_range;i>0;i--)
- printf(",\n P_T_MERGE(%s,%s) \t/* %s */",p,fix_typ,$1"_M"i)
- for (i=0;i<=cmd_range;i++)
- printf(",\n P_T_MERGE(%s,%s) \t/* %s */",p,fix_typ,$1"_"i)
- }
- printf(",\n P_T_MERGE(%s,%s) \t/* %s */",p,typ,$1)
- }
- #}}}
- END {
- printf("\n };\n")
- print("/*}}} */")
- }
-